package com.gitee.flyzing.jxt.component;

import com.gitee.flyzing.jxt.CommonUtil;
import org.apache.poi.ss.usermodel.Cell;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JXTValueCell extends JXTCell {
    @Override
    public void parseCell(Cell cell, Object datas) {
        String cellValue = cell.getStringCellValue();
        String exp = "\\{\\{\\s*(\\S*)\\s*\\}\\}";
        Pattern p = Pattern.compile(exp);
        Matcher m = p.matcher(cellValue);
        if (m.find()) {
            String propertyNames = m.group(1);
            Object itemProperty = CommonUtil.getPropertyValue(datas, propertyNames);
            if (itemProperty != null) {
                setCellValue(itemProperty.toString());
            }
        }
    }
}
